#ifndef DOCUMENT_H
#define DOCUMENT_H

#include <QObject>

class AbstractObject;
class Texture;
class Animation;
class GraphicsObject;

class CollisionShape;
class CollisionBox;
class CollisionCircle;
class CollisionPoly;

class Document : public QObject
{
    Q_OBJECT
public:
    explicit Document(QObject *parent = 0);

    bool isModified() const;
    void setModified(bool bValue);

    QPointer<GraphicsObject> createGraphicsObject(const QString& id);
    QPointer<Animation> createAnimation(const QString& id,
                                        QPointer<GraphicsObject> parent);
    QPointer<Texture> createTexture(const QString& id,
                                    QPointer<AbstractObject> parent, const QString& path = QString());

    QPointer<CollisionShape> createRectShape(const QRectF& rect);
    QPointer<CollisionShape> createCircleShape(const QPointF& center, float radius);
    QPointer<CollisionShape> createPolyShape(const QPolygonF& poly);

    bool deleteObject(QPointer<AbstractObject> object);

    QString currentFileName() const;

    QPointer<AbstractObject> currentObject() const;
    bool isEmpty() const;

    QList<QPointer<GraphicsObject> > graphicsObjects() const;
private:
    bool m_bModified;
    QString m_title;

    QString m_currentFileName;

    typedef QList<QPointer<GraphicsObject> > Objects;
    Objects m_objects;
    QPointer<AbstractObject> m_currentObject;
signals:
    void modifiedStateChanged(bool isModified);
    void objectCreated(QPointer<AbstractObject> object);
    void objectDeleted(QPointer<AbstractObject> object);
    void currentObjectChanged(QPointer<AbstractObject> object);
    void currentFilenameChanged(QString fileName);
public slots:
    void setCurrentObject(QPointer<AbstractObject> object);
    void setCurrentFileName(QString fileName);
};

#endif // DOCUMENT_H
